const express = require('express')
const mongoose = require('mongoose')
const bodyParser = require('body-parser')
const path = require('path')
const app = express()
app.use(express.static('pulic'))
app.use("/node_modules",express.static(path.join(__dirname,"/node_modules")))
app.use(bodyParser.urlencoded())
app.use(bodyParser.json())
const indexRouter = require("./routers")

app.use("/",indexRouter)
mongoose.connect('mongodb://localhost/b0445stu2').then(()=>{
    console.log('链接数据成功');
    app.listen(3001,()=>{
        console.log('服务器已启动');
        
    })
}).catch(error=>{
    console.log('链接数据失败',error);
    
})